const Controller = require('egg').Controller;
class HelloCotroller extends Controller {
    async index(){
        try{
            let data = await this.app.model.Hello.findAll();
            this.ctx.body = {
                code:200,
                msg:'请求成功',
                data:data
            }
        }catch{
            this.ctx.body = {
                code:501,
                msg:'查询失败',
            }
        }
    }
    async create(){
        let msg = this.ctx.request.body.data;
        let data = await this.ctx.service.hello.create(msg);
        this.ctx.body = data;
    }
    async update(){
        let msg = this.ctx.request.body.data;
        let data = await this.ctx.service.hello.update(msg);
        this.ctx.body=data
    }
    async destroy(){
        let msg = this.ctx.params.id;
        let data =await this.ctx.service.hello.destroy(msg)
        this.ctx.body=data;
    }
}

module.exports = HelloCotroller;